package com.up360.rapidcalc.common.rankinglist
{
    import com.up360.rapidcalc.common.util.IOHelper;
    
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.geom.Matrix;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLVariables;

    /**
     * @author Tunie
     * @date   May 7, 2013
     * Data Access Object
     * 数据访问对象
     */
    public class StudentDao
    {
        public function StudentDao()
        {
        }
        /**
         *访问提供的数据接口
         */
        public function access(url:String,vals:URLVariables,accessComp:Function,accessError:Function):void
        {
            IOHelper.request(url,vals,accessComp,accessError);
        }
        
        public function accessPortrait(url:String,container:Sprite):void
        {
            IOHelper.loadPic(url,loadPicComp,loadPicError);
            function loadPicComp(obj:DisplayObject):void
            {
                obj.width=container.width;
                obj.height=container.height;
                container.addChild(obj);
            }
            function loadPicError():void
            {
                trace("加载失败");
            }
        }
        
        public function newStudent(data:Object):Student
        {
            var b_tmp:Student=new Student();
            b_tmp.userName=data.userName;
            b_tmp.school=data.school;
            b_tmp.portrait=data.portrait;
            b_tmp.score=data.score;
            return b_tmp;
        }
    }
}